export function upload(params: {
  file: {
    url: string,
    size: number
  }
  uploadType?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15
}): Promise<any> {
  return new Promise((resolve, reject) => {
    let file = params.file
    let size = file.size / 1024 / 1024;
    if (size > 30) {
      wx.showToast({
        title: "文件大小不能超过30M",
        icon: "none"
      })
      reject('文件大小不能超过30M!')
    } else {
      wx.uploadFile({
        url: `https://ice.guojutech.net/Company/UploadMedia?companyVideoType=${params.uploadType || 1}`,
        header: {
          Authorization: 'Bearer ' + getApp().globalData.token
        },
        filePath: file.url,
        name: 'file',
        // formData: {  },
        success(res) {
          console.log(res);
          let data = JSON.parse(res.data)
          let url = data.Data
          resolve(url)
        },
        fail(res) {
          wx.showToast({
            title: "上传失败!",
            icon: "error"
          })
          reject(res)
        }
      });
    }
  })
}